<template>
    <div>
        <h1>66666666我的宝贝</h1>
        <p>姓名：<input type="text" v-model="form.name"></p>
        <p>年龄：<input type="text" v-model="form.age"></p>
        <button @click="add">添加</button>
        <table>
            <tr>
                <td>姓名</td>
                <td>年龄</td>
            </tr>
            <tr v-for="i in user">
                <td>{{i.name}}</td>
                <td>{{i.age}}</td>
            </tr>
        </table>
    </div>
    
</template>name

<script>
    export default {
        data() {
            return {
                form:{},
                user:[]
                
            }
        },
methods: {
    add(){
        this.$axios.post('/user',this.form)
      .then(res=>{
          if(res.data.code==200){

              alert('添加成功')          }
})
        },
    get_user(){
        this.$axios.get('/user')
        .then(res=>{
            then.user = res.data.list

        })

    }
},
mounted() {
    
    this.get_user()
},
        

}
        

</script>

<style scoped>

</style>